package com.kcyu.sfherp.mapper.ms;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kcyu.sfherp.entity.OrderZd;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderZdMapper extends BaseMapper<OrderZd> {

    @Select("select sum(sl * (jg - jj)) as ml, orchzd.dh, orchzd.id, orchzd.khbh, orchzd.khname, orchzd.je, orchzd.yf, orchzd.rq, orchzd.fkfs from orchzd inner join orchmx on orchzd.dh = orchmx.dh where orchzd.rq between N'${startTime} 00:00:00' and N'${endTime} 23:59:59' and orchzd.je <> 0 group by orchzd.dh, orchzd.id,orchzd.khbh, orchzd.khname, orchzd.je, orchzd.yf, orchzd.rq, orchzd.fkfs")
    List<OrderZd> UnionQuery(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select sum(sl * (jg - jj)) as ml, orchzd.dh, orchzd.id, orchzd.khbh, orchzd.khname, orchzd.je, orchzd.yf, orchzd.rq, orchzd.fkfs from orchzd inner join orchmx on orchzd.dh = orchmx.dh where orchzd.rq between N'${startTime} 00:00:00' and N'${endTime} 23:59:59' and orchzd.je <> 0 and orchzd.khname like '%${khname}%' group by orchzd.dh, orchzd.id,orchzd.khbh, orchzd.khname, orchzd.je, orchzd.yf, orchzd.rq, orchzd.fkfs")
    List<OrderZd> UnionQueryWithKhname(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("khname") String khname);
}
